#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

const int N = 210, off = 410;
int n, m, cnt, e_cnt;
int a[N], b[N], f[30][off << 1], sol[30][off << 1];

struct Edge {
	int v, nxt;
} e[N * off * 4];
inline void add(int x, int y, int v) {
	e[++e_cnt].v = v;
	e[e_cnt].nxt = sol[x][y];
	sol[x][y] = e_cnt;
}

void prt(int pos) {
	if (!pos) return;
	prt(e[pos].nxt);
	printf(" %d", e[pos].v);
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
	freopen("UVA323.in", "r", stdin);
	freopen("UVA323.out", "w", stdout);
#endif
#endif

	while (true) {
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0) break;
		++cnt;
		memset(f, 128, sizeof(f));
		memset(sol, 0, sizeof(sol));
		f[0][off] = 0;
		for (int i = 1; i <= n; ++i)
			scanf("%d%d", &a[i], &b[i]);
		for (int i = 1; i <= n; ++i) {
			for (int j = m; j; --j) {
				for (int k = -400; k <= 400; ++k) {
					if (f[j - 1][k + off - a[i] + b[i]] < 0) continue;
					if (f[j - 1][k + off - a[i] + b[i]] + a[i] + b[i] > f[j][k + off]) {
						f[j][k + off] = f[j - 1][k + off - a[i] + b[i]] + a[i] + b[i];
						sol[j][k + off] = sol[j - 1][k + off - a[i] + b[i]];
						add(j, k + off, i);
					}
				}
			}
		}
		int ans = -1, d = 0, p = 0, pos = 0;
		for (int i = 0; i <= 400; ++i) {
			ans = f[m][off + i], pos = i;
			if (f[m][off - i] > ans) ans = f[m][off - i], pos = -i;
			if (ans >= 0) break;
		}
		d = (ans + pos) >> 1, p = (ans - pos) >> 1;
		printf("Jury #%d\n", cnt);
		printf("Best jury has value %d for prosecution and value %d for defence:\n", d, p);
		prt(sol[m][pos + off]);
		puts("");
		puts("");
	}
	return 0;
}